package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import com.itheima.sercice.SetmealService;
import org.apache.ibatis.annotations.*;

import java.util.Map;

@Mapper
public interface SetmealDao {

    /**
     * 新增体检套餐
     * @param setmeal
     * @return
     */
    @Insert("insert into t_setmeal (name, code, helpCode, sex, age, price, remark, attention, img) " +
            "VALUES (#{name},#{code},#{helpCode},#{sex},#{age},#{price},#{remark},#{attention},#{img})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void add(Setmeal setmeal);

    /**
     * 添加套餐和检查组的多对多关系
     * @param map
     */
    @Insert("insert into t_setmeal_checkgroup (setmeal_id, checkgroup_id) values (#{setmeal_id},#{checkgroup_id})")
    void setSetmealCheckGroup(Map map);



    /**
     * 根据套餐id删除套餐
     * @param id
     * @return
     */
    @Delete("delete from t_setmeal_checkgroup where setmeal_id=#{id}")
    void deleteAssocication(Integer id);
    @Delete("delete from t_setmeal where id=#{id}")
    void delete(Integer id);

    /**
     * 根据id查询套餐
     * @param id
     * @return
     */
    @Select("select * from t_setmeal where id=#{id}")
    Setmeal findById(Integer id);

    /**
     * 修改检查套餐
     * @param setmeal
     * @return
     */
    void update(Setmeal setmeal);

    /**
     * 根据项目编码/名称/助记码分页查询检查套餐
     * @param queryString
     * @return
     */
    Page<CheckGroup> PageQuery(String queryString);
}
